<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>添加博客</title>
    <!-- Bootstrap -->
    <link href="../css/bootstrap.min.css" rel="stylesheet">
</head>

<body>

<div class="container">

    <form class="form-horizontal" style="width: 2000px;margin: 100px auto">
        <div class="form-group">
            <label for="title" class="col-sm-2 control-label">标题</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" id="title" placeholder="标题">
            </div>
        </div>
        <div class="form-group">
            <label for="desc" class="col-sm-2 control-label">描述</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" id="desc" placeholder="请简要描述一下博客内容">
            </div>
        </div>
        <div class="form-group">
            <label for="content" class="col-sm-2 control-label">内容</label>
            <div class="col-sm-4">
                <textarea class="form-control" rows="3" id="content"></textarea>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" class="btn btn-default" id="subBtn">提交</button>
                <button type="button" class="btn btn-default" id="returnBtn">返回</button>
            </div>
        </div>
    </form>
</div>

<script src="../js/jquery-3.2.1.js"></script>
<script>
    $("#subBtn").click(function () {
        $.ajax({
            url: "/blog/addblog",
            type: "post",
            data: {
                title: $("#title").val(),
                desc: $("#desc").val(),
                content: $("#content").val()
            },
            success:function (result) {
                if(result){
                    alert("添加成功");
                    window.location.href = "/user/blog"
                }
            }
        })
    });

    $("#returnBtn").click(function () {
        window.location.href = "/user/blog";
    });

</script>
</body>
</html>